import json
import random

import requests
import utils
import uuid

url = "http://127.0.0.1:18000/users/users/"
is_vaccine = [False, True]
status = [1, 1, 1, 1, 1, 1, 2, 2, 3]
name_generater = utils.BuildName()
area_generator = utils.AreaGenerator()
mobile_generator = utils.PhoneNOGenerator()


def create_persons():
    for i in range(1000000):
        payload = {'card_id': uuid.uuid4().hex[:20],
                   'name': name_generater.create_name(),
                   'permanent_residence': area_generator.get_area(),
                   'mobile': mobile_generator.phoneNORandomGenerator(),
                   'gender': random.randint(0, 2),
                   'age': random.randint(1, 120),
                   'is_vaccine': random.choice(is_vaccine),
                   'status': str(random.choice(status))}
        files = [
        ]
        headers = {}
        response = requests.request("POST", url, headers=headers, data=payload, files=files)
        print(response.text)


def create_rels():
    for i in range(100000):
        url = "http://127.0.0.1:18000/network/contacts/"
        payload = json.dumps({
            "o_node_id": random.randint(1, 1000000),
            "s_node_id": random.randint(1, 1000000),
            "rel_info": {
                "location_id": str(random.randint(1, 100)),
                "shaftWidth": str(random.randint(1, 10)),
                "time": "2020-0" + str(random.randint(1, 9)) + "-27"
            }
        })
        headers = {
            'Content-Type': 'application/json'
        }

        response = requests.request("POST", url, headers=headers, data=payload)

        print(response.text)


if __name__ == '__main__':
    create_rels()
